package com.shuang.springweb.dao;

import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NamedBean;
import org.springframework.beans.propertyeditors.PropertiesEditor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;
import org.springframework.validation.ValidationUtils;

import com.shuang.springweb.model.User;
import com.shuang.springweb.model.test.GoladTest;

@Repository
public class UserDao extends JdbcDaoBase {

	public final static Log log = LogFactory.getLog(UserDao.class);

	public UserDao() {
		System.out.println("UserDao");
	}

	public User get() {
		User user = getJdbcTemplate().queryForObject("select * from user",
				new BeanPropertyRowMapper<User>(User.class));
		return user;
	}

	public void save() {
	}

	public static void main(String[] args) throws SQLException {

		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"classpath*:spring/applicationContext-*.xml");
		System.out.println(ctx);
		UserDao userDao = ctx.getBean(com.shuang.springweb.dao.UserDao.class);
		//System.out.println(userDao.get());
		System.out.println();
		//log.info(userDao.get());
		
		System.out.println( ctx.getBean(GoladTest.class));
		PropertiesEditor p = new PropertiesEditor();
		
		BeanWrapper b = new BeanWrapperImpl();
	}

	
}
